package com.ddf.publics.entity;

import com.ddf.publics.tool.Constant;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 借贷申请表(LoanApplication)实体类
 *
 * @author norman
 * @since 2020-06-14 20:57:29
 */
public class LoanApplication implements Serializable {
    private static final long serialVersionUID = -90226005082239381L;
    /**
     * 编号
     * */    
    private Integer lId;
    /**
     * 申请人
     * */    
    private Integer userId;
    /**
     * 借款金额，单位为“千”
     * */    
    private Integer lMoney;
    /**
     * 借款期限，单位为“月”
     * */    
    private Integer lMonth;
    /**
     * 手机号
     * */    
    private String lPhone;
    /**
     * 身份证
     * */    
    private String identityCard;
    /**
     * 年龄
     * */    
    private Integer age;
    /**
     * 职业
     * */    
    private Integer occupation;
    /**
     * 月收入
     * */    
    private Integer monthlyProfit;
    /**
     * 所在公司名称
     * */    
    private String company;
    /**
     * 公司电话
     * */    
    private String companyPhone;
    /**
     * 住址
     * */    
    private String address;
    /**
     * 街道（门牌号等）
     * */    
    private String street;
    /**
     * 担保方式
     * */    
    private Integer guarantyStyle;
    /**
     * 抵押物品价值,单位为“万
     * */    
    private Float itemValue;
    /**
     * 借款用途
     * */    
    private String purposeOfLoan;
    /**
     * 借款描述
     * */    
    private String commentOfLoan;
    /**
     * 实际放款金额
     * */    
    private Integer maxMoney;
    /**
     * 贷款类型
     * */    
    private Integer loanType;
    /**
     * 订单时间
     * */    
    private Date orderTime;
    /**
     * 审核时间
     * */    
    private Date auditTime;
    /**
     * 订单状态
     * */    
    private Integer orderState;
    /**
     * 年利率
     * */    
    private Float interestRate;
    /**
     * 审核备注
     * */    
    private String auditComment;
    /**
     * 每月还款金额
     * */    
    private Float monthMoney;
    /**
     * 放款时间
     * */    
    private Date loanTime;

    @Override
    public String toString() {
        return "LoanApplication: {" +
                    ", lId=" + lId +
                    ", userId=" + userId +
                    ", lMoney=" + lMoney +
                    ", lMonth=" + lMonth +
                    ", lPhone=" + lPhone +
                    ", identityCard=" + identityCard +
                    ", age=" + age +
                    ", occupation=" + occupation +
                    ", monthlyProfit=" + monthlyProfit +
                    ", company=" + company +
                    ", companyPhone=" + companyPhone +
                    ", address=" + address +
                    ", street=" + street +
                    ", guarantyStyle=" + guarantyStyle +
                    ", itemValue=" + itemValue +
                    ", purposeOfLoan=" + purposeOfLoan +
                    ", commentOfLoan=" + commentOfLoan +
                    ", maxMoney=" + maxMoney +
                    ", loanType=" + loanType +
                    ", orderTime=" + orderTime +
                    ", auditTime=" + auditTime +
                    ", orderState=" + orderState +
                    ", interestRate=" + interestRate +
                    ", auditComment=" + auditComment +
                    ", monthMoney=" + monthMoney +
                    ", loanTime=" + loanTime +
                    '}';
    }


    public Integer getLId() {
        return lId;
    }

    public void setLId(Integer lId) {
        this.lId = lId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getLMoney() {
        return lMoney;
    }

    public void setLMoney(Integer lMoney) {
        this.lMoney = lMoney;
    }

    public Integer getLMonth() {
        return lMonth;
    }

    public void setLMonth(Integer lMonth) {
        this.lMonth = lMonth;
    }

    public String getLPhone() {
        return lPhone;
    }

    public void setLPhone(String lPhone) {
        this.lPhone = lPhone;
    }

    public String getIdentityCard() {
        return identityCard;
    }

    public void setIdentityCard(String identityCard) {
        this.identityCard = identityCard;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getOccupation() {
        return occupation;
    }

    public void setOccupation(Integer occupation) {
        this.occupation = occupation;
    }

    public Integer getMonthlyProfit() {
        return monthlyProfit;
    }

    public void setMonthlyProfit(Integer monthlyProfit) {
        this.monthlyProfit = monthlyProfit;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getCompanyPhone() {
        return companyPhone;
    }

    public void setCompanyPhone(String companyPhone) {
        this.companyPhone = companyPhone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public Integer getGuarantyStyle() {
        return guarantyStyle;
    }

    public void setGuarantyStyle(Integer guarantyStyle) {
        this.guarantyStyle = guarantyStyle;
    }

    public Float getItemValue() {
        return itemValue;
    }

    public void setItemValue(Float itemValue) {
        this.itemValue = itemValue;
    }

    public String getPurposeOfLoan() {
        return purposeOfLoan;
    }

    public void setPurposeOfLoan(String purposeOfLoan) {
        this.purposeOfLoan = purposeOfLoan;
    }

    public String getCommentOfLoan() {
        return commentOfLoan;
    }

    public void setCommentOfLoan(String commentOfLoan) {
        this.commentOfLoan = commentOfLoan;
    }

    public Integer getMaxMoney() {
        return maxMoney;
    }

    public void setMaxMoney(Integer maxMoney) {
        this.maxMoney = maxMoney;
    }

    public Integer getLoanType() {
        return loanType;
    }

    public void setLoanType(Integer loanType) {
        this.loanType = loanType;
    }

    public Date getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Date orderTime) {
        this.orderTime = orderTime;
    }

    public Date getAuditTime() {
        return auditTime;
    }

    public void setAuditTime(Date auditTime) {
        this.auditTime = auditTime;
    }

    public Integer getOrderState() {
        return orderState;
    }

    public void setOrderState(Integer orderState) {
        this.orderState = orderState;
    }

    public Float getInterestRate() {
        return interestRate;
    }

    public void setInterestRate(Float interestRate) {
        this.interestRate = interestRate;
    }

    public String getAuditComment() {
        return auditComment;
    }

    public void setAuditComment(String auditComment) {
        this.auditComment = auditComment;
    }

    public Float getMonthMoney() {
        return monthMoney;
    }

    public void setMonthMoney(Float monthMoney) {
        this.monthMoney = monthMoney;
    }

    public Date getLoanTime() {
        return loanTime;
    }

    public void setLoanTime(Date loanTime) {
        this.loanTime = loanTime;
    }

    public void setUserInfo(User user,UserInfo userInfo){
        this.identityCard = userInfo.getIdCard();
//        this.lPhone = user.getPhone();
        this.userId = user.getId();
        this.orderTime = new Date();
        this.orderState = Constant.LOAN_ORDER_STATE_AUDIT;
        String identity = userInfo.getIdCard();
        String nian =  identity.substring(6,10);
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
        String navdate = simpleDateFormat.format(date);
        this.age = Integer.parseInt(navdate)-Integer.parseInt(nian);
    }

}